const session = require('koa-session')

app.keys = ['some secret hurr']

const CONFIG = {
  key: 'koa:sess', /** 默认 */
  /** (number || 'session') maxAge in ms (default is 1 days) */
  /** 'session' will result in a cookie that expires when session/browser is closed */
  /** Warning: If a session cookie is stolen, this cookie will never expire */
  maxAge: 86400000, /*cookie的过期时间 {需要修改}*/
  overwrite: true, /** (boolean) can overwrite or not (default true) */
  httpOnly: true, /** (boolean) httpOnly or not (default true) */
  signed: true, /** (boolean) signed or not (default true) */
  rolling: true, /** 在每次请求时强行设置cookie， 这将重置cookie过期时间（默认false）{需要修改} */
  renew: false, /** {需要修改}*/
};

app.use(session(CONFIG, app));

//设置
ctx.session.username = '张三'
//获取
ctx.session.username